<template>
	<view class="container">
		<uni-nav-bar @clickRight="clickRight" @clickLeft="clickLeft"  fixed="true" left-icon="bars" right-icon="search" title="网易云音乐" background-color="#d44439" color="white"></uni-nav-bar>
		<view class="nav">
			<text v-for="(item,index) in nav" :key="index" :class="{red:isred === index}" @click="change(index,item)">{{item}}</text>
		</view>
		<view class="contanct" v-for="item in info" :key="item.id">
			<view class="inside">
				<video :src="item.singUrl"></video>
			</view>
			<p>{{item.name}}</p>
			<view class="art">
				<view class="img">
					<!--  #ifdef  MP-WEIXIN -->
					<image :src="item.cover"></image>
					<!--  #endif -->
					<!--  #ifndef  MP-WEIXIN -->
					<img  v-lazy="item.cover">
					<!--  #endif -->
				</view>
				<text class="artistName">{{item.artistName}}</text>
				<view class="right">
					<text>点赞:{{item.likedCount}}</text>
					<text>评论:{{item.commentCount}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {mv,Mvurl,info} from '../../../api/video/video.js'
	export default {
		data() {
			return {
				info:[],
				nav:['内地','港台','欧美','日本','韩国'],
				isred:0,
				ischangeRed:false
			}
		},
		onLoad(){
			mv({type:'官方版',limit:10,area:'内地'}).then(res => {
				this.info = res.data
				for(let i = 0;i<this.info.length;i++){
					Mvurl({id:this.info[i].id}).then(res => {
						//console.log(res)
						let url = res.data.url
						this.$set(this.info[i], 'singUrl', url)
					})
					info({mvid:this.info[i].id}).then(res => {
						//console.log(res)
						let commentCount = res.commentCount
						let likedCount = res.likedCount
						this.$set(this.info[i], 'commentCount', commentCount)
						this.$set(this.info[i], 'likedCount', likedCount)
					})
				}
				console.log(this.info)
			})
		},
		methods:{
			clickLeft(){
				uni.navigateTo({
					url:'../../ZuiJinBoFang/ZuiJinBoFang'
				})
			},
			clickRight(){
				uni.navigateTo({
					url:'../../SouSuo/SouSuo'
				})
			},
			change(index,item){
				this.isred = index
				mv({type:'官方版',limit:10,area:item}).then(res => {
					this.info = res.data
					for(let i = 0;i<this.info.length;i++){
						Mvurl({id:this.info[i].id}).then(res => {
							let url = res.data.url
							this.$set(this.info[i], 'singUrl', url)
						})
						info({mvid:this.info[i].id}).then(res => {
							//console.log(res)
							let commentCount = res.commentCount
							let likedCount = res.likedCount
							this.$set(this.info[i], 'commentCount', commentCount)
							this.$set(this.info[i], 'likedCount', likedCount)
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.container{
		width: 750rpx;
		background-color: #e6e6e6;
		.nav{
			width: 100%;
			height: 140rpx;
			background-color: white;
			display: flex;
			align-items: center;
			justify-content: space-around;
			.red{
				color: red;
			}
		}
		.contanct{
			margin-top: 20rpx;
			background-color: white;
			.inside{
				width: 100%;
				height: 450rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				video{
					height: 400rpx;
				}
			}
			p{
				padding-left: 70rpx;
				margin-top: 30rpx;
				font-size: 40rpx;
				height: 70rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				word-break: normal;    
			}
			.art{
				width: 100%;
				height: 140rpx;
				//background-color: red;
				display: flex;
				align-items: center;
				justify-content: space-around;
				border-top: 2rpx solid #e6e6e6;
				.img{
					height: 80rpx;
					width: 80rpx;
					padding-left: 70rpx;
					/*  #ifdef  MP-WEIXIN  */
					image{
						border-radius: 200rpx;
						width: 100%;
						height: 100%;
					}
					/*  #endif  */
					/*  #ifndef  MP-WEIXIN  */
					img{
						border-radius: 200rpx;
						width: 100%;
						height: 100%;
					}
					/*  #endif  */
					
				}
				.artistName{
					margin-left: 20rpx;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
					word-break: normal;    
				}
				.right{
					height: 100%;
					width: 300rpx;
					display: flex;
					align-items: center;
					justify-content: space-around;
					text{
						font-size: 24rpx;
					}
					.changeRed{
						color: red;
					}
				}
			}
		}
	}
</style>
